package com.zhoux.controller;

import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author taoyi
 * @version 1.0
 * @date 2021/6/28 23:27
 */
@RestController
@RequestMapping("/provider")
public class RestProviderController {



    /**
     * 添加操作
     * @param map
     * @return
     */
    @PostMapping
    public Map<String,Object> doCreate(
            @RequestBody  Map<String,Object> map){
        //....后续要将请求数据写入到数据库
        System.out.println("provider.map="+map);
        //定义响应结果
        Map<String,Object> responseMap=new HashMap<>();
        responseMap.put("status",200);
        responseMap.put("message","insert ok");
        return responseMap;
    }

    /**
     * 删除操作
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public String doDeleteById(@PathVariable Integer id){
        System.out.println("provider.id="+id);
        return id + "is delete";
    }


    /**
     * 更新操作
     * @param map
     * @return
     */
    @PutMapping
    public Map<String,Object> doUpdate(
            @RequestBody  Map<String,Object> map){
        //....后续要将请求数据写入到数据库
        System.out.println("provider.map="+map);
        //定义响应结果
        Map<String,Object> responseMap=new HashMap<>();
        responseMap.put("status",200);
        responseMap.put("message","update ok");
        return responseMap;
    }

}
